package KUtilities;

public class KCipher{
	
	public static String encrypt(String message){
		char msg[]=message.toCharArray();
		char encrypted[]=new char[msg.length];
		encrypted[0]=msg[0];
		for(int i=1;i<msg.length;i++){
			encrypted[i]=(char)(msg[i-1]+msg[i]);
		}
		return new String(encrypted);
	}
	
	public static String decrypt(String message){
		char msg[]=message.toCharArray();
		char decrypted[]=new char[msg.length];
		decrypted[0]=msg[0];
		for(int i=1;i<msg.length;i++){
			decrypted[i]=(char)(msg[i]-decrypted[i-1]);
		}
		return new String(decrypted);
	}
}
